package com.cmj.Utils;

import com.cmj.domain.entity.*;

import java.util.Date;

/**
 * 设置这四个属性createBy createTime updateBy updateTime
 */
public class SetCbytimeUbytime {

    //设置创建
    public static <T extends Comment> T setCreate(T t){
        t.setCreateBy(SecurityUtils.getUserId());
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setCreateTime(new Date());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Article> T setCreate(T t){
        t.setCreateBy(SecurityUtils.getUserId());
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setCreateTime(new Date());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Category> T setCreate(T t){
        t.setCreateBy(SecurityUtils.getUserId());
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setCreateTime(new Date());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Link> T setCreate(T t){
        t.setCreateBy(SecurityUtils.getUserId());
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setCreateTime(new Date());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends User> T setCreate(T t){
        t.setCreateTime(new Date());
        t.setUpdateTime(new Date());
        return t;
    }

    //设置更新
    public static <T extends Comment> T setUpdate(T t){
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Article> T setUpdate(T t){
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Category> T setUpdate(T t){
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends Link> T setUpdate(T t){
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setUpdateTime(new Date());
        return t;
    }
    public static <T extends User> T setUpdate(T t){
        t.setUpdateBy(SecurityUtils.getUserId());
        t.setUpdateTime(new Date());
        return t;
    }
}
